import tkinter as tk

def toggle_checkbox():
    if checkbox_var.get() == 1:
        print("Checkbox is checked")
    else:
        print("Checkbox is unchecked")


if __name__ == '__main__':
    window = tk.Tk()

    # 创建复选框
    checkbox_var = tk.IntVar()
    checkbox = tk.Checkbutton(window, text="Check me", variable=checkbox_var, command=toggle_checkbox)
    checkbox.pack()

    window.mainloop()